
import 'dart:async';

import 'package:ayj_flutter_chat_app/common/configs/project_config.dart';
import 'package:ayj_flutter_chat_app/common/third/agora/engine/agora_engine_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../../common/configs/dimens.dart';
import '../../../../common/configs/enums.dart';
import '../../../../common/configs/styles.dart';
import '../../../../common/utils/jh_string_utils.dart';


class FloatingVoiceWidget extends StatefulWidget {

  const FloatingVoiceWidget({
    super.key,
  });

  @override
  State<FloatingVoiceWidget> createState() => _FloatingVoiceWidgetState();
}

/// 换绑手机-校验页面
class _FloatingVoiceWidgetState extends State<FloatingVoiceWidget> {


  @override
  Widget build(BuildContext context) {

    MeetingStatusType type = AgoraEngineController.to.voiceMeetingType.value;

    if(MeetingStatusType.call == type){
      return Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          _buildImage(),
          SizedBox(height: 8.h,),
          Text('等待对方应答...',
            style: KStyles.commonFontWeightTextStyle(Colours.color333333, KDimens.font_sp15),),
        ],
      ).addContainer(width: 90.w,height: 88.h,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(4.r),
        ),
      );
    }

    if(MeetingStatusType.waiting == type){
      return Center(
        child: _buildImage(),
      ).addContainer(width: 90.w,height: 88.h,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(4.r),
        ),
      );
    }

    if(MeetingStatusType.received == type){
      return Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          _buildImage(),
          SizedBox(height: 8.h,),
          Obx(()=> Text(JhStringUtils.hms_dateFormatSeconds(AgoraEngineController.to.count.value),
              style: KStyles.commonFontWeightTextStyle(Colours.color333333, KDimens.font_sp15)),
          ),
        ],
      ).addContainer(width: 90.w,height: 88.h,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(4.r),
        ),
      );
    }

    return const SizedBox();
  }

  Widget _buildImage(){
    return AppImage.assets(AppR.chat_meeting_voice_call,width: 28.w,height: 28.w,);
  }

}